Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/volunteer view modal css #2893 #3097

Conversation

Dhiren-Mhatre
Copy link
Contributor

@Dhiren-Mhatre Dhiren-Mhatre commented Dec 31, 2024

Pull Request Title

Refactor CSS in src/screens/EventVolunteers/Volunteers/VolunteerViewModal.tsx (#2893)

What kind of change does this PR introduce?

Refactoring

Issue Number

Fixes #2893

Did you add tests for your changes?

No. (Refactoring does not require new tests as functionality remains unchanged.)

Snapshots/Videos

Screenshot from 2024-12-30 14-19-29

If relevant, did you update the documentation?

N/A

Summary

This PR addresses issue #2893, which involves refactoring the CSS within the src/screens/EventVolunteers/Volunteers/VolunteerViewModal.tsx file.

Motivation for the change:

  • To enhance the UI/UX of Talawa-Admin for colorblind users.
  • To streamline all CSS into a single global file (src/style/app.module.css).

Tasks completed:

  1. Moved all embedded CSS in VolunteerViewModal.tsx to the global CSS file (src/style/app.module.css).
  2. Removed all embedded CSS from VolunteerViewModal.tsx.

Reference

Foundational work for this change was initiated in PR #2466 (Chore/css changes).

Does this PR introduce a breaking change?

No.

Other information

  • The refactored CSS adheres to the design pattern established in src/style/app.module.css.
  • Improved maintainability and consistency of CSS across the application.

Have you read the contributing guide?

Yes.

Summary by CodeRabbit

  • Style Updates
    • Refined styling for the Volunteer View Modal
    • Added new CSS classes for improved visual consistency
    • Enhanced status indicators with distinct styling for accepted and pending statuses
    • Improved table and form element presentations

Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

Walkthrough

The pull request focuses on refactoring the CSS in the VolunteerViewModal.tsx component by moving embedded CSS styles to the global app.module.css file. The changes involve renaming and standardizing CSS class names across the component, such as updating modal, form, image, status, and table-related classes. The primary goal is to improve UI/UX by streamlining CSS into a single global file and making the application more suitable for color-blind users.

Changes

File Change Summary
src/screens/EventVolunteers/Volunteers/VolunteerViewModal.tsx - Renamed CSS classes for modal, title, close button, form, image, status, and table elements
- Removed inline styles
- Added conditional class assignments for status
src/style/app.module.css - Added new CSS classes: .modalTitle, .modalForm, .formGroup, .tableImage
- Added status-related classes: .statusGroup, .statusIcon, .acceptedStatus, .pendingStatus
- Added classes for hours field, groups label, table headers, and rows

Assessment against linked issues

Objective Addressed Explanation
Refactor CSS in VolunteerViewModal.tsx [#2893]
Move embedded CSS to global file
Make application more suitable for color-blind users

Possibly related issues

Possibly related PRs

Suggested reviewers

  • palisadoes

Poem

🐰 CSS dancing, classes align,
Volunteer modal now looks so fine!
From scattered styles to one global home,
A rabbit's refactor, no more to roam! 🎨✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
src/style/app.module.css (2)

4132-4134: Consider using CSS custom properties for spacing.

The margin could be defined using a CSS custom property to maintain consistency with other spacing values in the codebase.

.formGroup {
-  margin-bottom: 1rem;
+  margin-bottom: var(--spacing-md, 1rem);
}

4136-4141: Consider using existing custom properties for consistency.

The table styles could leverage existing custom properties for dimensions and borders.

.tableImage {
-  width: 40px;
-  height: 40px;
+  width: var(--table-image-small-size);
+  height: var(--table-image-small-size);
  border-radius: 50%;
  margin-right: 8px;
}

Also applies to: 4186-4193

src/screens/EventVolunteers/Volunteers/VolunteerViewModal.tsx (5)

55-57: Use semantic heading for modal title
Consider using a heading element (<h4> or <h5>) instead of a <p> tag for better accessibility and semantics, given this text denotes the modal title.


61-61: data-testid vs. CSS class
Renaming the data-testid attribute to match the new class naming convention (e.g., "modalCloseButton") would help maintain consistency.


86-86: Ensure “tableImage” is correct for modal display
Currently named tableImage, but this usage is in a form context. Consider renaming to something more specific to the modal if needed.


118-121: Hover tooltip for status icons
Adding a title or aria-label to the <HistoryToggleOff> icon might improve accessibility by indicating the meaning of the icon.


143-143: Descriptive label
“Volunteer Groups Joined” is a user-friendly label, though ensuring it’s translated (i.e., using t() for i18n) would be more consistent with the rest of the strings.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b12325e and a61c6a7.

📒 Files selected for processing (2)
  • src/screens/EventVolunteers/Volunteers/VolunteerViewModal.tsx (7 hunks)
  • src/style/app.module.css (2 hunks)
🔇 Additional comments (12)
src/style/app.module.css (2)

4124-4130: LGTM! Modal structure follows best practices.

The modal layout classes provide appropriate spacing and structure.


4174-4184: LGTM! Field styles are well-implemented.

The field styles make good use of CSS custom properties for colors and provide appropriate typography styles.

src/screens/EventVolunteers/Volunteers/VolunteerViewModal.tsx (10)

68-68: Consistent naming convention
Using modalForm here is aligned with the convention established in other parts of the codebase. Good job keeping it consistent.


70-70: Semantic grouping
<Form.Group> is appropriate for grouping form controls. Ensure that each group has an associated label for accessibility compliance.


93-93: Manage container styles carefully
The containerStyle and avatarStyle props both reference styles. Verify that the additional imageContainer class is well-defined in app.module.css to avoid layout conflicts.


107-107: Separation of form groups
Using statusGroup clarifies the grouping of related fields. This is a good practice for readability and maintainability.


116-116: Clear icon usage
<TaskAlt color="success" ... /> clarifies the user’s acceptance status. Good use of icons to reinforce text-based status.


125-127: Dynamic style assignment
Using conditional logic to toggle between acceptedStatus and pendingStatus is a clear and extensible approach.


135-135: Multiple class names
Combining noOutline and hoursField is correct. Just confirm that both classes do not override essential styles for each other.


155-161: Table headers
Nice use of a shared tableHeader class. Confirm that these headings are properly announced to screen readers by verifying <th> usage or ARIA attributes if needed.


170-170: Styling for table rows
Applying tableRow is consistent with the other table styling. This helps ensure a uniform appearance across all rows.


193-193: Export statement
Ensuring a default export for VolunteerViewModal is correct and convenient for importing. No issues observed.

src/style/app.module.css Outdated Show resolved Hide resolved
@palisadoes
Copy link
Contributor

Please make coderabbit.ai approve your PR

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.25%. Comparing base (6ce8c1b) to head (e1e38ea).
Report is 3 commits behind head on develop-postgres.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           develop-postgres    #3097       +/-   ##
=====================================================
+ Coverage             25.41%   89.25%   +63.83%     
=====================================================
  Files                   301      322       +21     
  Lines                  7618     8421      +803     
  Branches               1667     1897      +230     
=====================================================
+ Hits                   1936     7516     +5580     
+ Misses                 5555      670     -4885     
- Partials                127      235      +108     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

aadhil2k4 and others added 2 commits December 31, 2024 22:56
…ar/OrganizationSidebar.tsx (PalisadoesFoundation#3096)

* Improved Code Coverage in src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.tsx

* Unit test documentation
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
.github/workflows/pull-request.yml (1)

83-83: LGTM with a minor suggestion.

The added error message provides clear instructions to users. However, consider enhancing it to be more informative.

-          echo "Error: Close this PR and try again."
+          echo "Error: Close this PR and create a new one with different source and target branches."
src/style/app.module.css (2)

4136-4141: Enhance image handling for better user experience.

Consider adding styles to handle different image aspect ratios and loading states:

 .tableImage {
   width: 40px;
   height: 40px;
   border-radius: 50%;
   margin-right: 8px;
+  object-fit: cover;
+  background-color: var(--bs-gray-200);
 }

4155-4169: Previous accessibility improvements for status indicators were implemented.

The status indicators now include high contrast outlines and proper padding, making them more accessible for colorblind users.

Consider adding status icons to further improve accessibility:

 .acceptedStatus {
   color: var(--bs-primary);
   -webkit-text-fill-color: var(--bs-primary);
   outline: 1px solid currentColor;
   border-radius: 4px;
   padding: 2px 4px;
+  &::before {
+    content: "✓";
+    margin-right: 4px;
+  }
 }

 .pendingStatus {
   color: var(--bs-warning);
   -webkit-text-fill-color: var(--bs-warning);
   outline: 1px solid currentColor;
   border-radius: 4px;
   padding: 2px 4px;
+  &::before {
+    content: "⏳";
+    margin-right: 4px;
+  }
 }
src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.spec.tsx (2)

181-198: Consider adding explicit error mocks to fully validate GraphQL error scenarios.

Currently, using mockId = 'error' triggers the fallback content expectation, but the error scenario is not explicitly defined in the MOCKS array as a failing GraphQL request. It may still pass if there is no matching mock, but for thorough testing, consider returning a mock GraphQLError to verify the error path more explicitly.


215-236: Include alt-text verifications for accessibility compliance.

Testing the presence and correctness of profile images is good. However, for best practices, consider verifying alt attributes to ensure compliance with accessibility guidelines and a good user experience for screen readers.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a61c6a7 and 6a760d3.

📒 Files selected for processing (4)
  • .github/workflows/pull-request.yml (1 hunks)
  • src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.spec.tsx (2 hunks)
  • src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.tsx (0 hunks)
  • src/style/app.module.css (2 hunks)
💤 Files with no reviewable changes (1)
  • src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/style/app.module.css

[error] 4148-4148: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

🔇 Additional comments (6)
src/style/app.module.css (4)

4124-4134: LGTM! Modal layout styles are clean and well-structured.

The modal styles follow a clear hierarchy with appropriate spacing.


4171-4181: LGTM! Form field and label styles are consistent with the application's design.

The styles provide good visual hierarchy with appropriate font weights and sizes.


4183-4190: LGTM! Table styles follow clean and consistent patterns.

The table styles provide good visual structure with appropriate font weights and border handling.


4143-4149: ⚠️ Potential issue

Remove invalid CSS property 'role'.

The 'role' property should be an HTML attribute, not a CSS property.

 .statusGroup {
   display: flex;
   gap: 1rem;
   margin: 0 auto;
   margin-bottom: 0.5rem;
-  role: 'status';
 }

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 4148-4148: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.spec.tsx (2)

27-29: Great documentation expansion for new test scenarios.

The descriptive comments provide clarity on each test case, making the test suite more maintainable and self-explanatory.


200-213: Excellent loading state test coverage.

Verifying the presence of two "Loading..." indicators confirms proper UI feedback for both members and events. This approach is concise and ensures that users see the expected loading elements before data is fetched.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 31, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/style/app.module.css (1)

4155-4169: Enhance status indicators with additional accessibility features.

While the high-contrast outlines improve visibility for colorblind users, consider adding these accessibility enhancements:

.acceptedStatus {
  color: var(--bs-primary);
  -webkit-text-fill-color: var(--bs-primary);
  outline: 1px solid currentColor;
  border-radius: 4px;
  padding: 2px 4px;
+  /* Add icon for non-color indication */
+  &::before {
+    content: '✓';
+    margin-right: 0.25rem;
+  }
}

.pendingStatus {
  color: var(--bs-warning);
  -webkit-text-fill-color: var(--bs-warning);
  outline: 1px solid currentColor;
  border-radius: 4px;
  padding: 2px 4px;
+  /* Add icon for non-color indication */
+  &::before {
+    content: '⌛';
+    margin-right: 0.25rem;
+  }
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a760d3 and e1e38ea.

📒 Files selected for processing (1)
  • src/style/app.module.css (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/style/app.module.css

[error] 4148-4148: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

🔇 Additional comments (4)
src/style/app.module.css (4)

4124-4130: LGTM! Modal structure styles are clean and well-organized.

The modal title and form styles follow standard practices with appropriate spacing.


4183-4190: LGTM! Table styles are well-structured.

The table header and row styles are clean and handle border cases appropriately.


4132-4141: LGTM! Form element styles are well-defined.

The form group, image, hours field, and label styles follow best practices with appropriate spacing and typography.

Also applies to: 4171-4181


4143-4149: ⚠️ Potential issue

Remove invalid CSS property 'role'.

The 'role' property is not valid CSS. This attribute should be moved to the HTML element.

.statusGroup {
  display: flex;
  gap: 1rem;
  margin: 0 auto;
  margin-bottom: 0.5rem;
-  role: 'status';
}

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 4148-4148: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

@palisadoes palisadoes merged commit a52c095 into PalisadoesFoundation:develop-postgres Dec 31, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants